'use strict';const _0u={oper:"filter",params:{tgtExpr:"<windowId>",refExpr:"<windowId>"}},_Ak={oper:"sort",params:{order:"mru",desc:!0}};
_2i.tse={other:{value:[]},currentTab:{name:"Current tab",help:"cur",value:""},prevUsedTab:{name:"Previous tab",help:"prv",value:[_0u,_Ak,{oper:"filter",params:{pos:"next",wrap:!0}}]},nextUsedTab:{name:"Next tab",help:"nxt",value:[_0u,_Ak,{oper:"filter",params:{pos:"prev",wrap:!0}}]},prevUsedTabAnyWin:{name:"Previous tab (any win.)",help:"prvAll",value:[_Ak,{oper:"filter",params:{pos:"next",wrap:!0}}]},nextUsedTabAnyWin:{name:"Next tab (any win.)",help:"nxtAll",value:[_Ak,{oper:"filter",params:{pos:"prev",
wrap:!0}}]},activeTabs:{name:"Active tabs",help:"act",value:[{oper:"filter",params:{tgtExpr:"<active>",refExpr:"true"}}]},activeTab:{name:"Active tab",help:"act0",value:[{oper:"filter",params:{tgtExpr:"<active>",refExpr:"true"}}]},openerTab:{name:"Opener tab",help:"opnr",value:[{oper:"filter",params:{tgtExpr:"<id>",refExpr:"<openerTabId>"}}]},leftTab:{name:"Left tab",help:"lft",value:[_0u,{oper:"filter",params:{pos:"prev"}}]},leftTabWrap:{name:"Left tab (wrap)",help:"",value:[_0u,{oper:"filter",params:{pos:"prev",
wrap:!0}}]},rightTab:{name:"Right tab",help:"rgt",value:[_0u,{oper:"filter",params:{pos:"next"}}]},rightTabWrap:{name:"Right tab (wrap)",help:"",value:[_0u,{oper:"filter",params:{pos:"next",wrap:!0}}]},firstTab:{name:"Leftmost tab",help:"",value:[_0u,{oper:"slice",params:{from:1,to:1}}]},lastTab:{name:"Rightmost tab",help:"",value:[_0u,{oper:"slice",params:{from:-1,to:-1}}]},newestTab:{name:"Newest tab",help:"nwst",value:[_0u,{oper:"sort",params:{order:"creation"}},{oper:"slice",params:{from:-1,to:-1}}]},
hoveredTabs:{name:"Hovered tab",help:"hvr",value:[{oper:"filter",params:{anyHvrd:!0}}]},allLeftTabs:{name:"All tabs to the left",help:"",multi:1,value:[_0u,{oper:"filter",params:{pos:"before"}}]},allRightTabs:{name:"All tabs to the right",help:"",multi:1,value:[_0u,{oper:"filter",params:{pos:"after"}}]},eventTabs:{name:"Event tab",help:"evt",value:[{oper:"filter",params:{evtTabs:!0}}]},highlighted:{name:"Selected tabs",help:"hlt",multi:1,value:[_0u,{oper:"filter",params:{tgtExpr:"<highlighted>",refExpr:"true"}}]},
pinnedTabs:{name:"Pinned tabs",help:"pin",multi:1,value:[_0u,{oper:"filter",params:{tgtExpr:"<pinned>",refExpr:"true"}}]},audibleTabs:{name:"Audible tabs",help:"aud",multi:1,value:[{oper:"filter",params:{tgtExpr:"<audible>",refExpr:"true"}}]},nonMinimTabs:{name:"Non-minimized tabs",help:"vsbl",multi:1,value:[{oper:"filter",params:{tgtExpr:"<window.state>",refExpr:"minimized",negate:!0}},{oper:"filter",params:{tgtExpr:"<window.state>",refExpr:"hidden",negate:!0}}]},otherTabs:{name:"Other tabs (curr. window)",
help:"othr",multi:1,value:[_0u,{oper:"filter",params:{tgtExpr:"<active>",refExpr:"false"}}]},otherTabsAllWins:{name:"Other tabs (all windows)",help:"othrAll",multi:1,value:[{oper:"filter",params:{tgtExpr:"<id>",refExpr:"<id>",negate:!0}}]},currWinTabs:{name:"All tabs (curr. window)",help:"",multi:1,value:[_0u]},currWinTabsMruOrder:{name:"All tabs (curr. window, MRU order)",help:"curWmru",multi:1,value:[_0u,_Ak]},allTabs:{name:"All tabs (all windows)",multi:1,value:[]},allTabsMruOrder:{name:"All tabs (all windows, MRU order)",
help:"allMru",multi:1,value:[_Ak]}};_2i.tse.add({righTab:_2i.tse.rightTab,righTabWrap:_2i.tse.rightTabWrap});
function _gt(b){if(!b.ufOper)return b;b.oper=b.ufOper;delete b.ufOper;let a=b.params||{};"string"==typeof a.refTab&&(a.refTab=_9g(_er(a.refTab,"tse").value));"string"==typeof a.tabSet&&(a.tabSet=_9g(_er(a.tabSet,"tse").value));if(a.compOper&&a.compOper.in("contains","starts","ends")){let d=("starts"==a.compOper?"^":"")+_Lt(a.refExpr||"","^$\\.*+?()[]{}|")+("ends"==a.compOper?"$":"");a.refExpr={templ:d,regex:!0}}delete a.compOper;a.tgtExpr&&(a.tgtExpr.in("prev","next","before","after")?(a.pos=a.tgtExpr,
delete a.tgtExpr):"openerTabId"==a.tgtExpr?(a.tgtExpr="<openerTabId>",a.refExpr="<id>"):"windowId"==a.tgtExpr?a.tgtExpr=a.refExpr="<windowId>":"groupId"==a.tgtExpr?a.tgtExpr=a.refExpr="<groupId>":"favList"==a.tgtExpr?delete a.tgtExpr:"evtTabs"==a.tgtExpr&&(delete a.tgtExpr,a.evtTabs=!0));"reverse"==a.order&&(b.oper=a.order);return b}const _6=new WeakMap;let _It=0;
function _Ei(b,a=!0){"string"==typeof b&&(b=_er(b,"tse").value);if(!b)return b;if(a&&_6.has(b))return _6.get(b);const d=b;b=_9g(b);for(let c of b)_gt(c),"filter"==c.oper?(c.params.tgtExpr=_Mu(c.params.tgtExpr),c.params.refExpr=_Mu(c.params.refExpr),c.params.refTab=_Ei(c.params.refTab,!1)):"sort"==c.oper?c.params.order=_Mu(c.params.order):"addSet"==c.oper?(++_It,c.params.tabSet=20<_It?[]:_Ei(c.params.tabSet,!1),--_It):"groupBy"==c.oper&&(c.params.expr=_Mu(c.params.expr));a&&_6.set(d,b);return b}
function _4j(b,a){return _Aj(_Ei(b),a)}function _Aj(b,a){if(!b)return _Ca?[[_Ca]]:[[]];a=a?a.slice():[_od];a[0]||(a[0]=[]);for(let d of b)d.oper&&(a=_Xy(a,d.oper,d.params),a[0]||(a[0]=[]));return a}function _Nd(b){return[...new Set(_3y(...b))]}function _Hg(b,a,d){a=Math.max(1,(a||1)+(0>a?b.length+1:0))-1;d=Math.max(a,(d||b.length)+(0>d?b.length+1:0));return b.slice(a,d)}
function _Xy(b,a,d){if("mergeGrp"==a)return[_Nd(b)];if("addSet"==a){var c=_Aj(d.tabSet);return d.replace?c:b.concat(c)}if("slice"==a&&d.groupWise)return _Hg(b,d.from,d.to);if("reverse"==a&&d.groupWise)return b.slice().reverse();c=[];a=_Fe[a];for(let e of b)c.push(...e.length?a(e,d):[]);return c}const _Fe={filter:_tw,posFilter:_tw,sort:_7i,groupBy:_zs,reverse:b=>[b.slice().reverse()],slice:(b,a)=>[_Hg(b,a.from,a.to)]};
function _7i(b,a){let d=a.order;a=a.desc;switch(d){case "normal":b=_1(b,_od);break;case "mru":b=_1(b,_Ek,!0);break;case "zOrder":b=_Qf(b);break;case "creation":b=_1(b,_Mh,!0);break;default:let c={};for(let e of b)c[e]=_yy(d,_os[e]);b=b.slice().sort((e,f)=>{e=c[e];f=c[f];return e==f?0:e<f?-1:1})}a&&b.reverse();return[b]}
function _Qf(b){if(_lw)return _Hu.addFunc(_Ii(function*(){_lw&&(yield _fw(_ef),_lw=!1)})),b.slice();let a=0;for(let d of _8d)_sk[d].zIndex=a--;_Ek=_1(_od,_Ek,!0);for(let d of b)_os[d].mruIndex=_Ek.indexOf(d);return b.slice().sort((d,c)=>{let e=_os[d].window.zIndex-_os[c].window.zIndex;return e?e:_os[d].mruIndex-_os[c].mruIndex})}
function _zs(b,a){let d=_Dr();for(let c of b){if("overlapArea"==a.expr){let e=_ti(_os[c].window);b=0;for(let [,f]of d){let h=_ti(_os[f[0]].window);if(_9u(_Tj(e),h)||_9u(_Tj(h),e))break;++b}}else b=_yy(a.expr,_os[c]);d[b]||(d[b]=[]);d[b].push(c)}return[...d].map(([,c])=>c)}let _4r;function _Kh(){if(_4r)return _4r;_Hu.addFunc(_Ii(function*(){_4r=yield _fw(_z,{usePrvMsPos:!!_7o(_wy).usePrevMousePos})}));return{}}
function _Kf(b=!1,a=!1,d=!1){const c={TSE:g=>_3y(..._4j(g)),tabList:g=>g,tab:g=>[g]};let e=[],f=g=>{(g=_Zy(g))&&g.type in c&&e.push(...c[g.type](g.content))},h=_Kh();b&&h.marked&&f(h.marked);a&&h.hilited&&f(h.hilited);d&&h.hovered&&f(h.hovered);return[...new Set(e)].filter(g=>g in _os)}
function _tw(b,a){let d=[],c;if(a.favList)c=_7f[a.favList]||[];else if(a.evtTabs)c=_qd(_wy);else if("menuSeltn"==a.tgtExpr)c=_Kf(a.marked,a.hilited,a.hovered);else if(a.anyHvrd)c=_Kf(!1,!1,!0),c.length||(c=_Cp(),c.length||(c=[_Kg(_sk,_ra(),"activeTab","id")]));else if("grpSize"==a.tgtExpr)return a.min<=b.length&&b.length<=a.max?[b]:[];if(c)d=b.filter(f=>0<=c.indexOf(f)==!a.negate);else{var e=_os[a.refTab?_Aj(a.refTab,[b])[0][0]:_Ca];if(e)if(a.pos)d=_5u(b,a,e.id),a.negate&&(d=b.filter(f=>-1==d.indexOf(f)));
else{e=_yy(a.refExpr,e);for(let f of b)b=_yy(a.tgtExpr,_os[f]),(b instanceof RegExp?b.test(e):e instanceof RegExp?e.test(b):String(b)==String(e))==!a.negate&&d.push(f)}}return[d]}function _5u(b,a,d){var c=b.indexOf(d);if(0>c)return[];b=[b.slice(0,c),b.slice(c+1).reverse()];c=a.pos.in("before","prev");let e=b[+!c].reverse();a.addRef&&e.unshift(d);a.wrap&&(e=e.concat(b[+c]));a.pos.in("prev","next")&&(e=e.slice(0,1));return e};
